﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChoicePers_Left.aspx.cs" Inherits="Common_ChoicePers_Left" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link href="../CSS/css.CSS" type="text/css" rel="stylesheet" /> 
    <script language ="javascript" type="text/javascript" >
    <!--  

function ck(obj,obj1){
if(obj.lowsrc=="") return true;
obj.imgRolln=obj.src;
obj.src=obj.lowsrc;
obj.lowsrc=obj.imgRolln;
if(obj1.style.display=='none')
   obj1.style.display='';
else
   obj1.style.display='none';
}

var GOrgInfo = "" ;
var GNextOrgID = "";      //本级及下级部门ID集合
var GNoRepeatOrgID = "";  //得到本级及下级不重复部门ID集合
var GPersCount = "0";     //当前树中所关联到的人员数;
var GOrgCount = "0";      //当前树中所关联到的组织数;
//显示树型

function showtree(space_c,ParentIDCol)
{
    var aPCol = ParentIDCol.split(',');
    var iPcol = aPCol.length;
    for(m=0;m<iPcol;m++)
    {
      show_tree(space_c,aPCol[m]);
    }
}

function show_tree(space_c,ParentID)
{
  var i,j,k,img_src1,img_src2; 
  for(k=0;k<trees.length;k++)
  {
    if(trees[k].ParentID == ParentID || (trees[k].ChildNumber == "0" && trees[k].ID == ParentID ))
    {      
      document.write("<table border=0 cellspacing=0 cellpadding=0 bordercolor=#000000 width=100%><tr><td>");      
      for(i=1;i<=space_c;i++)
        document.write("&nbsp;&nbsp;");
        
      if(GOrgInfo!="")
      {
        if(trees[k].ID != ParentID)
        {
           img_src1="../SysManage/img/sys/close.gif";
           img_src2="../SysManage/img/sys/open.gif";
        } 
        var ary  = GOrgInfo.split(',');
        var nary = ary.length;
        for(i=0;i<nary-1;i++)
        { 
          if(trees[k].ID == ary[i])
          {
            img_src1="../SysManage/img/sys/open.gif";
            img_src2="../SysManage/img/sys/close.gif";
          }
          if(trees[k].ParentID == ary[i])
          {
             img_src1="../SysManage/img/sys/close.gif";
             img_src2="../SysManage/img/sys/open.gif";
           }
        }        
      }
      else
      {
           img_src1="../SysManage/img/sys/close.gif";           
           img_src2="../SysManage/img/sys/open.gif";           
      }
      if(trees[k].ChildNumber=="0")
      {
        img_src1="../SysManage/img/sys/open.gif";        
        img_src2="../SysManage/img/sys/open.gif";
      }
      document.write("<img lowsrc=" + img_src2 + " id=\"img_"+trees[k].ID+"\" onclick=\"ck(this,document.all.T" + trees[k].ID + ");\" src=" + img_src1 + " align=middle>&nbsp;<a  style=\"cursor:pointer\" onclick=\"tog(this,'#f3f3f3');sendCtrlNodeInfo('" + trees[k].ID + "','" + trees[k].Name +  "'); \" >" + trees[k].Name + "</a></td></tr></table>");
      document.write ("<span id='T" + trees[k].ID + "' style='display:none'>" );
      if(trees[k].ChildNumber != "0")
      {
        show_tree(space_c +1 ,trees[k].ID);
      }  
      document.write ("</span>");     
    }
  }
}

function sendCtrlNodeInfo(sID,sName,sParentID,sChildNumber,sPersNumber,sDOrder,sPhone,sPrincipal,sPrincipalName,sFax,sEffective,sPrentName)
{
  eval("parent.RightFrame.location.href = \"ChoicePers_List.aspx?OpType=2&PersName=&PersCode=&OrgID="+sID+"&OrgName="+sName+"\";");
  //GOrgInfo = "" ;
  //alert(sID + "," + sName + "," + sParentID + "," + sChildNumber + "," + sDOrder + "," + sEffective);
  //hidform.hOrgInfo.value = sID + "," + sName + "," + sParentID + "," + sChildNumber +"," + sPersNumber + "," + sDOrder +"," + sPhone +"," + sPrincipal +"," + sPrincipalName +"," + sFax + "," + sEffective + "," + sPrentName ;
  //GetSuperOrgID(sID);
  
  //  hidform.hOrgID.value = sID;
  //  hidform.hParentOrgID.value = sParentID;
  //  hidform.hPersNumber.value = sPersNumber;
  //  hidform.hChildNumber.value = sChildNumber;
    //alert(sID); 
}

function ClearItem()
{
    GNextOrgID = "";
    sGetPersIDCol = ""; 
}

//展开收缩下一级部门
function SpreadNextOrgTree(DeptID,ChildNum)
{
  var i,j,k,img_src1,img_src2;
  if(ChildNum!="0")
  {
    if(eval("document.all.T"+DeptID+".style.display")=='none')
    {
      eval("document.all.T"+DeptID+".style.display=''");    //展开下级层
      eval("document.all.img_"+DeptID+".src=\"../SysManage/img/sys/open.gif\";");    //展开下级层
      eval("document.all.img_"+DeptID+".lowsrc=\"../SysManage/img/sys/close.gif\";");    //展开下级层
    }
    else
    {
      eval("document.all.T"+DeptID+".style.display='none'");    //收缩下级层
      eval("document.all.img_"+DeptID+".src=\"../SysManage/img/sys/close.gif\";");    //收缩下级层
      eval("document.all.img_"+DeptID+".lowsrc=\"../SysManage/img/sys/open.gif\";");    //收缩下级层
    }
  }
}

function GetNextOrgID(OrgID)   //取得同级及下级部门ID的集合.为选择人员做准备
{
  var k;
  GNextOrgID = GNextOrgID + OrgID+",";
  for(k=0;k<trees.length;k++)
  {
    var TempStr = "";
    if(trees[k].ParentID == OrgID)   //当前组织的ID
    {
      TempStr = TempStr + trees[k].ID + ",";
      GetNextOrgID(trees[k].ID);
      GNextOrgID = GNextOrgID + TempStr ;
    }
  }
}

//去掉重复的数据
function DelRepeatData(sData)
{
   ClearItem();
   var ary = sData.split(',');
   var iary = ary.length;
   for(i=0;i<ary.length;i++)
   {
       var itype = 0;
       for (j=i+1;j<ary.length;j++)
       {
          if(ary[i] ==ary[j])
          {
            itype =1;
            break;
          }
       }
       if(itype == 0 && i!= iary-1)
       {
         GNextOrgID = GNextOrgID + ary[i] + ",";
       }
       else
       {
         itype =0;
       }
   }
   var Lindex = GNextOrgID.lastIndexOf(',');  //取最后一个匹配值的索引
   var sCutData = GNextOrgID.substr(0,Lindex);
   eval("parent.RightFrame.location.href = \"ChoicePers_List.aspx?OpType=2&PersName=&PersCode=&OrgID="+sCutData+"&OrgName=\";");
}

//自动展开新组织的所有上级组织  OrgID是要展开的组织\

function GetSuperOrgID(OrgID)   //取得上级部门ID的集合.为展开树做准备的.
{
  var k;
  for(k=0;k<trees.length;k++)
  {
    var TempStr = "";
    if(trees[k].ID == OrgID)   //当前组织的ID
    {
      TempStr = TempStr + trees[k].ID + ",";
      GetSuperOrgID(trees[k].ParentID);
      GOrgInfo = GOrgInfo + TempStr ;
    }
  }
}

//展开一个新树

function SpreadNewOrgTree()
{  
  var i,j,k,img_src1,img_src2;
      if(GOrgInfo!="")
      {
        var ary  = GOrgInfo.split(',');
        var nary = ary.length;
        for(i=0;i<nary-1;i++)
        {
          eval("document.all.T"+ary[i]+".style.display=''");
        } 
      }
      else
      {
        //alert(GOrgInfo);
      }
}

var tgs; 
var tmp_background_val; 
function tog(n,flags)
{ 
  if (tgs)
  { 
    tgs.style.background= tmp_background_val ; 
  } 
  n.style.background= '#99ccff'; 
  tmp_background_val=flags;
  tgs=n; 
} 
-->
    </script>
    
</head> 
    <body >
      <table cellpadding ="0" cellspacing ="0" width="98%" align="center" >
       <tr>       
        <td><%=sDeptHtml%></td>        
       </tr>
      </table> 
      <form id = "hidform" method="post" runat ="server">
        <input type="hidden" id="hOrgInfo" runat ="server" />
        <input type="hidden" id="hOrgID" runat ="server" />
        <input type="hidden" id="hParentOrgID" runat ="server" />
        <input type="hidden" id="hChildNumber" runat ="server" />
        <input type="hidden" id="hPersNumber" runat ="server" />
        <input type="hidden" id="hOrgType" runat ="server" />
      </form>
  </body>
</html>